<?php

/*

Forums (forums.php)

*/

$interactive = 1;
$page_title = "Forums";
$rank_check = 3;
include "header.inc.php";

$findCategories = mysql_query("SELECT * FROM forum_cats2 WHERE game = '$game' ORDER BY id");
$numCats = mysql_num_rows($findCategories);
if ($numCats == 0)
{
	if ($rank == 7)
	{
		$ifAdmin = "<br>Admins: Click <a href=admin/admin_add_cat.php?game=$game>here</a> to add categories!";
	}

	$categoryList = "<TR BGCOLOR=\"$reallyLight\"> <TD HEIGHT=40 COLSPAN=3><center>There are currently no categories to choose from!$ifAdmin</center></TD></TR>";
}

while ($getCats = mysql_fetch_array($findCategories))
{
	$cellcolor = alternate($cellcolor,"$reallyLight","#FFFFFF");
	$get_responder = fetch("SELECT username,display_name,premium,display_prem FROM members2 WHERE id = '$getCats[last_poster]' AND game = '$game'");
	if (($get_responder[premium] == 1) AND ($get_responder[display_prem]))
	{
		$get_responder[display_name] = $get_responder[display_prem];
	}

	if ($getCats[last_post])
	{
		$lastpost_string = date("g:i:s, M j",$getCats[last_post]) . "<BR>by <A
HREF=\"$base_url/user_profile.php?game=$game&user=$get_responder[username]\">$get_responder[display_name]</A>";
	}
	if (!$getCats[last_post]) { $lastpost_string = "<i>no posts</i>"; }

	$numTopics    = fetch("SELECT count(id) AS id FROM forum_subjects2 WHERE game = '$game' AND category = '$getCats[id]'");

	$categoryList .= "<TR BGCOLOR=\"$cellcolor\" onmouseover=\"this.style.background='$middleBG';\" onmouseout=\"this.style.background='$cellcolor';\"><TD
HEIGHT=40> <P><A HREF=\"$base_url/view.php?game=$game&id=$getCats[id]\">$getCats[cat_name]</A><BR> <FONT
SIZE=\"-1\">&#187; $getCats[cat_desc]</FONT></P> </TD> <TD WIDTH=110 HEIGHT=40>
<p align=center>$numTopics[id] Topics</p> </TD> <TD
HEIGHT=40 width=118> <p align=center><FONT SIZE=\"-1\">$lastpost_string</font></p>
</TD></TR>";
	$numPosts[id] = 0;
}

print "$openHTML";

$findPage = fetch("SELECT * FROM game_pages WHERE page_title = '$page_title' AND game = '$game'");
if (!$findPage[id])
{
	print "<p><b>Welcome to the forums. Failure to obey the rules may result in suspension of your account. <font color=red>Remember to Keep it clean, anything over PG will bedeleted.</font></b></p>";

}
else
{
	include "showpage.inc.php";
	print "$findPage[page_info]";
}

ECHO <<<END

<center><table><tr>
<td>
<form action=add_topic.php?game=$game method=post>
<input type=submit value="Add Topic">
</form>
</td>
<td>
<form action=view.php?game=$game&order=last25 method=post>
<input type=submit value="Last 25 Posts">
</form>
</td>
<td>
<form action=view.php?game=$game&order=newest25 method=post>
<input type=submit value="Newest 25 Posts">
</form>
</td>
<td>
<form action=view.php?game=$game&order=yourTopics method=post>
<input type=submit value="Your Topics">
</form>
</td>
<td>
<form action=search_forums.php?game=$game method=post>
<input type=submit value="Search Forums">
</form>
</td>

</tr></table>

<p><TABLE BGCOLOR="$tableOutline" CELLSPACING=1 CELLPADDING=0 WIDTH="95%">
   <TR BGCOLOR="$topAndBottomBG"><TD
HEIGHT=20> <P><font color=$topAndBottomText><b>Category</b></font></P> </TD> <TD WIDTH=110 HEIGHT=20>
<p align=center><font color=$topAndBottomText><b>Threads</b></font></p> </TD> <TD
HEIGHT=20 width=118> <p align=center><font color=$topAndBottomText><b>Last Post</b></font></font></p>
</TD></TR>

$categoryList

<TR> <TD COLSPAN=4 HEIGHT=30 BGCOLOR="$topAndBottomBG"> <p align=center><FONT SIZE="-1"
COLOR="#FFFFFF"><I>(You must be at least 13 to use the $gameName2
Forums!)</I></FONT></p> </TD> </TR>

</TABLE>
</CENTER>


END;

print "$closeHTML";
?>